keyMap = {
    "globalSize": "全局网格尺寸",
    "damageCount": "损伤数量",
    "damageType": "损伤类型",
    "damageCenterX": "损伤中心位置x",
    "damageCenterY": "损伤中心位置y",
    "damageCenterZ": "损伤中心位置z",
    "honeycombCoreHeight": "蜂窝芯子高度",
    "damageExcisionDiameter": "损伤挖除直径",
    "submodelSizeL": "子模型尺寸长度",
    "submodelSizeW": "子模型尺寸宽度",
    "搭接宽度": "Overlap width",
    "adhesiveLayerThickness": "胶层厚度",
    "additionalExcisionSize": "额外挖除尺寸",
    "lowerAdhesiveLayersCount": "下铺层修补胶层层数",
    "topPlyNumber": "上铺层层数",
    "topRepairPlyNumber": "上铺层修补层层数",
    "bottomRepairPlyNumber": "下铺层修补层层数",
    "bottomPlyNumber": "下铺层层数",
    "topPlyTable": "上铺层",
    "bottomPlyTable": "下铺层",
    # "topRepairPlyTable": "上铺层修补层",
    # "bottomRepairPlyTable": "下铺层修补层",
    "honeycombCore": "蜂窝芯子材料",
    "bottomFillPlyTable": "下铺层填充层",
    "loadCondition": "载荷工况",
    "loadAmplitude": "载荷幅值",
    "厚度": "厚度",
    "材料名称": "材料名称",
    "Angle": "铺层角度",
    "铺层名称": "铺层名称",
    "method": "优化功能",
    "algorithm": "优化算法",
    "goal": "优化目标",
    "constraints": "约束条件",
    "lapWidthTable": "搭接宽度(优化)",
    "topAngleTable": "上铺层修补层",
    "bottomAngleTable": "下铺层修补层",
    "replaceCoreTable": "替换蜂窝芯子",
    "material": "材料",
    "presetModelPath": "预设模型路径",
    "shapeParameter": "形状参数",
    "specimenCoefficient": "试件系数",
    "confidenceCoefficient": "置信系数",
    "reliabilityCoefficient": "可靠性系数",
    "lifeAnalysisResults": "寿命统计结果",
    "statisticsTable": "寿命统计情况",
}

valueMap = {
    "全局网格尺寸": "globalSize",
    "损伤数量": "damageCount",
    "损伤类型": "damageType",
    "损伤中心位置x": "damageCenterX",
    "损伤中心位置y": "damageCenterY",
    "损伤中心位置z": "damageCenterZ",
    "蜂窝芯子高度": "honeycombCoreHeight",
    "损伤挖除直径": "damageExcisionDiameter",
    "子模型尺寸长度": "submodelSizeL",
    "子模型尺寸宽度": "submodelSizeW",
    "Overlap width": "搭接宽度",
    "胶层厚度": "adhesiveLayerThickness",
    "额外挖除尺寸": "additionalExcisionSize",
    "下铺层修补胶层层数": "lowerAdhesiveLayersCount",
    "上铺层层数": "topPlyNumber",
    "上铺层修补层层数": "topRepairPlyNumber",
    "下铺层修补层层数": "bottomRepairPlyNumber",
    "下铺层层数": "bottomPlyNumber",
    "上铺层": "topPlyTable",
    "下铺层": "bottomPlyTable",
    # "上铺层修补层": "topRepairPlyTable",
    # "下铺层修补层": "bottomRepairPlyTable",
    "蜂窝芯子材料": "honeycombCore",
    "下铺层填充层": "bottomFillPlyTable",
    "载荷工况": "loadCondition",
    "载荷幅值": "loadAmplitude",
    "厚度": "厚度",
    "材料名称": "材料名称",
    "铺层角度": "Angle",
    "铺层名称": "铺层名称",
    "优化功能": "method",
    "优化算法": "algorithm",
    "优化目标": "goal",
    "约束条件": "constraints",
    "搭接宽度(优化)": "lapWidthTable",
    "上铺层修补层": "topAngleTable",
    "下铺层修补层": "bottomAngleTable",
    "替换蜂窝芯子": "replaceCoreTable",
    "材料": "material",
    # "材料":"Type of material",
    "预设模型路径": "presetModelPath",
    "形状参数": "shapeParameter",
    "试件系数": "specimenCoefficient",
    "置信系数": "confidenceCoefficient",
    "可靠性系数": "reliabilityCoefficient",
    "寿命统计结果": "lifeAnalysisResults",
    "寿命统计情况": "statisticsTable",
}


def convertKey(data, type, isNoList=False):
    res = {}
    if type == 0:
        for key, values in data.items():
            # if valueMap.get(key):
            #     res[valueMap.get(key) or ""] = values
            # else:
            # res[key] = values
            res[valueMap.get(key) or ""] = values
            if isinstance(values, list) and not isNoList:
                newValues = []
                for item in values:
                    subDict = {}
                    for k, v in item.items():
                        subDict[valueMap.get(k) or ""] = v
                    newValues.append(subDict)
                res[valueMap.get(key) or ""] = newValues
    elif type == 1:
        for key, values in data.items():
            res[keyMap.get(key) or ""] = values
            if isinstance(values, list) and not isNoList:
                newValues = []
                for item in values:
                    subDict = {}
                    for k, v in item.items():
                        subDict[keyMap.get(k) or ""] = v
                    newValues.append(subDict)
                res[keyMap.get(key) or ""] = newValues
    return res
